//
//  AUAddressPickerProtocol.swift
//  CreditLoans
//
//  Created by 谢强 on 2017/12/8.
//  Copyright © 2017年 com.ucfpay. All rights reserved.
//

// 回调
typealias AUSelectedCallback = (_ address: String, _ childs: [AUAddressPickerModel]?) -> ()

// Runtime_Key
struct AUAddressPickerRuntimeKey {
    static let selectedCallbackKey: UnsafeRawPointer! = UnsafeRawPointer.init(bitPattern: "selectedCallbackKey".hashValue)
}

protocol AUAddressPickerProtocol where Self: UIViewController {
    
    // 回调
    var selectedCallback: (AUSelectedCallback)? { get }
    
}

extension AUAddressPickerProtocol {
    
    // 回调
    var selectedCallback: (AUSelectedCallback)? {
        get {
            return objc_getAssociatedObject(self, AUAddressPickerRuntimeKey.selectedCallbackKey) as? AUSelectedCallback
        }
        set {
            objc_setAssociatedObject(self, AUAddressPickerRuntimeKey.selectedCallbackKey, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
        }
    }
    
}
